<template>
    <AppSortable v-model="verticalList"
            direction="vertical"
            item-key="id"
            handle="handle"
            item-class="draggable-item"
            >
            <template #item="{ item, index }">
                <div class="handle">:::</div>
                <div class="item-content">{{ item.content }}</div>
            </template>
    </AppSortable>
</template>
<script lang="ts" setup>
import { AppSortable } from 'vue3-sortable';
import {ref} from 'vue';

const verticalList = ref([
    { id: crypto.randomUUID(), content: "例子1"},
    { id: crypto.randomUUID(), content: "例子2"},
    { id: crypto.randomUUID(), content: "例子3" },
  ]);
</script>

<style >
 .draggable-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 6px;
    background-color: #3eaf7c;
    color: white;
    font-weight: 500;
    box-shadow: 0 2px 4px rgba(62, 175, 124, 0.2);
    transition: all 0.2s ease;
    user-select: none;
  }

  .handle {
    cursor: grab;
    padding: 8px 6px;
    border-radius: 4px;
    color: white;
    font-weight: bold;
    user-select: none;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
  }

  .drag-handle:hover {
    background-color: rgba(255, 255, 255, 0.2);
  }

  .drag-handle:focus {
    outline: none;
    background-color: rgba(255, 255, 255, 0.3);
    box-shadow: 0 0 0 3px rgba(62, 175, 124, 0.3);
  }

  .is-dragging {
    opacity: 0.5;
    transform: scale(0.95);
  }

  .is-dragging .drag-handle {
    cursor: grabbing;
  }

  .item-content {
    flex: 1;
    font-size: 14px;
  }</style>